import Vue from 'vue'
import VueRouter from 'vue-router'

const UserIndex = () => import('../views/user/Index')
const UserPost = () => import('../views/user/Post')
const UserInfo = () => import('../views/user/Info')
const UserArt = () => import('../views/user/Art')
const FollowList = () => import('../views/user/Follow')
const FavorList = () => import('../views/user/Favor')

const AdminIndex = () => import('../views/admin/Index')
const AdminInfo = () => import('../views/admin/Info')
const AdminUser = () => import('../views/admin/User')
const AdminPl = () => import('../views/admin/Pl')
const AdminWorks = () => import('../views/admin/Works')
const AdminAtcCheck = () => import('../views/admin/AtcCheck')
const AdminList = () => import('../views/admin/Admins')

Vue.use(VueRouter)

const routes = [
  {
    path: '/admin',
    component: AdminIndex,
    name: '管理员',
    nav: false,
    redirect: '/admin/info',
    children: [
      {
        path: '/admin/info',
        name: '总览',
        component: AdminInfo,
        meta:{
          nav: true
        }
      },
      {
        path: '/admin/review',
        name: '文章审核',
        component: AdminAtcCheck,
        meta:{
          nav: true
        }
      },
      {
        path: '/admin/article',
        name: '文章管理',
        component: AdminWorks,
        meta:{
          nav: true
        }
      },
      {
        path: '/admin/cmt',
        name: '评论管理',
        component: AdminPl,
        meta:{
          nav: true
        }
      },
      {
        path: '/admin/list',
        name: '管理员',
        component: AdminList,
        meta:{
          nav: true
        }
      },
    ]
  },
  {
    path: '/',
    component: UserIndex,
    name: '用户',
    nav: false,
    redirect: '/info',
    children: [
      {
        path: '/info',
        name: '信息',
        component: UserInfo,
        meta:{
          nav: true
        }
      },
      {
        path: '/article',
        name: '文章管理',
        component: UserArt,
        meta:{
          nav: true
        }
      },
      {
        path: '/post',
        name: '投稿',
        component: UserPost,
        meta:{
          nav: true
        }
      },
      {
        path: '/followList',
        name: '关注',
        component: FollowList,
        meta:{
          nav: false
        }
      },
      {
        path: '/fansList',
        name: '粉丝',
        component: FollowList,
        meta:{
          nav: false
        }
      },
      {
        path: '/favor',
        name: '收藏夹',
        component: FavorList,
        meta:{
          nav: true
        }
      },
    ]
  },

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
